package cn.edu.cug.cs.gtl.apis.render.basics;

import cn.edu.cug.cs.gtl.apis.render.NativeObjectWrapper;

public interface Box3f extends NativeObjectWrapper {
    /**
     * Returns the squared maximum distance between a point and the 8 bounding box's vertices.
     * @param p
     * @return
     */
    float	computeMaxDistance2(Vec3f p);

    /**
     * Returns true if the specified box is fully contained inside this box.
     * @param bb
     * @return
     */
    boolean	contains(Box3f bb);

    /**
     * Extends this box (if necessary) to contain the specified box.
     * @param bb
     */
    void	extendBy(Box3f bb);

    /**
     * Extends this box (if necessary) to contain the specified point.
     * @param pt
     */
    void	extendBy(Vec3f pt);

    /**
     * Gets the corners of the box.
     * @return
     */
    float[]	getBounds();

    /**
     * Sets the corners of the box.
     * @param xmin
     * @param ymin
     * @param zmin
     * @param xmax
     * @param ymax
     * @param zmax
     */
    void	setBounds(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax);

    /**
     * Sets the corners of the box.
     * @param _min
     * @param _max
     */
    void	setBounds(Vec3f _min, Vec3f _max);

    /**
     * Returns the center of the box.
     * @return
     */
    Vec3f	getCenter();

    /**
     * Returns the closest point on the box to the given point.
     * @param point
     * @return
     */
    Vec3f	getClosestPoint(Vec3f point);

    /**
     * Returns the maximum point of the box.
     * @return
     */
    Vec3f	getMax();

    /**
     * Returns the minimum point of the box.
     * @return
     */
    Vec3f	getMin();

    /**
     * Gets the corners of the box.
     * @return
     */
    Vec3f[]	getMinMax();

    /**
     * Gets box origin which is the same as the minimum corner of the box.
     * @return
     */
    float[]	getOrigin();

    /**
     * Gets box size.
     * @return
     */
    Vec3f	getSize();

    /**
     * Finds the span of a box along a specified direction.
     * @param direction
     * @return
     */
    float[]	getSpan(Vec3f direction);

    float[]	getValue();

    /**
     * Returns the volume of the box.
     * @return
     */
    float	getVolume();

    /**
     * Returns true if all three dimensions of the box have positive size, and false otherwise.
     * @return
     */
    boolean	hasVolume();

    /**
     * Returns true if the specified box intersects this box.
     * @param bb
     * @return
     */
    boolean	intersect(Box3f bb);

    /**
     * Returns true if the specified point intersects this box.
     * @param pt
     * @return
     */
    boolean	intersect(Vec3f pt);

    /**
     * Returns the intersection of the specified box with this box.
     * @param box
     * @return
     */
    Box3f	intersection(Box3f box);

    /**
     * Returns true if the box is empty, and false otherwise.
     * @return
     */
    boolean	isEmpty();


    /**
     * Makes an empty box.
     */
    void	makeEmpty();

    /**
     * Returns true if bounding box is completely outside the view-volume defined by the model+view+projection matrix given.
     * @param MVP
     * @return
     */
    int	outside(Matrix MVP);


    Box3f	setValue(float[] components);
    Box3f	setValue(float[] components, int startIndex);
    void	setValue(Box3f copyFrom);

    /**
     * Transforms box by matrix, enlarging box to contain result.
     * @param m
     */
    void	transform(Matrix m);


    /**
     * Return true if the given triangle intersects the bounding box.
     * @param u0
     * @param u1
     * @param u2
     * @return
     */
    boolean	triangleBoxOverlap(Vec3f u0, Vec3f u1, Vec3f u2);

}
